package device

import (
	"context"
	"devops-super/api/product/v1"
	"devops-super/internal/service"
)

// GetPageLst 分页获取设备列表
func (*ControllerV1) GetPageLst(ctx context.Context, req *v1.DeviceGetPageLstReq) (res *v1.DeviceGetPageLstRes, err error) {
	res = &v1.DeviceGetPageLstRes{}
	res.PageLstRes, err = service.Device().GetPageLst(ctx, req)
	return
}

// Add 新增设备
func (*ControllerV1) Add(ctx context.Context, req *v1.DeviceAddReq) (res *v1.DeviceAddRes, err error) {
	res, err = service.Device().Add(ctx, req)
	return
}

// Upt 更新设备
func (*ControllerV1) Upt(ctx context.Context, req *v1.DeviceUptReq) (res *v1.DeviceUptRes, err error) {
	res, err = service.Device().Upt(ctx, req)
	return
}

// UptStatus 更新设备状态
func (*ControllerV1) UptStatus(ctx context.Context, req *v1.DeviceUptStatusReq) (res *v1.DeviceUptStatusRes, err error) {
	err = service.Device().UptStatus(ctx, req.Id, req.OpenStatus)
	return
}

// Del 删除设备
func (*ControllerV1) Del(ctx context.Context, req *v1.DeviceDelReq) (res *v1.DeviceDelRes, err error) {
	err = service.Device().Del(ctx, req.Id)
	return
}

// GetOne 获取单条设备
func (*ControllerV1) GetOne(ctx context.Context, req *v1.DeviceGetOneReq) (res *v1.DeviceGetOneRes, err error) {
	res1, err := service.Device().GetOne(ctx, req.Id)
	if err != nil {
		return
	}
	res = new(v1.DeviceGetOneRes)
	res.Info = res1
	return
}

// GetOptions 获取设备选项
func (*ControllerV1) GetOptions(ctx context.Context, req *v1.DeviceGetOptionsReq) (res *v1.DeviceGetOptionsRes, err error) {
	res, err = service.Device().GetOptions(ctx, req)
	return
}

func (*ControllerV1) GetCopies(ctx context.Context, req *v1.DeviceGetCopiesReq) (res *v1.DeviceGetCopiesRes, err error) {
	res, err = service.Device().GetCopies(ctx, req)
	return
}
